import { $get } from '@js/request'
import { CaseSchema } from '@components/Schema/CaseSchema'

// 获取案件列表
export async function getCaseListRequest (searchText: string, status: string): Promise<CaseSchema[]> {
  const condition = []
  if (searchText !== '') {
    condition.push({ k: 'caseno_desc', o: 'like', v: `%${searchText}%` })
  }
  const d: { [k: string]: any } = {
    page_size: 1000,
    current: 1,
    condition: JSON.stringify(condition)
  }
  if (status !== '全部') {
    d.status = status
  }
  const res = await $get('/api/xd/case/findCaseByAccountid', d)
  if (res.status !== 1) {
    throw new Error(res.message)
  }
  return res.data.list.map((li: CaseSchema, i: number) => {
    li.order = i + 1
    return li
  })
}
